//api中没有显示出来doc是属于app的

//api中怎么找不到Collab中的collectEmailInfo、getIcon、GetCosObj
//找到了Collab中的addStateModel和removeStateModel



var util = {
	printf : function(a,b){print ("//[alert] CVE-2008-2992  CVE-2008-1104 util.printf length ("+ a.length + "," + b.length + ")\n"); },
	printd : function(){ print("//[alert] warning CVE-unknown printd access"); },
};

//把Annotation类模拟出来把
//api中没有Page类

//本来应该是doc.info.XX的,但是样本中也有直接是this.info所以我在这里单独列出来了
//最后在解析的时候,jsunpack的做法是info.%s = String(\"%s\");但是也加上了app.doc.%s = String(\"%s\");
var info = { title : '',
             author:'',
             subject:'',
             keywords:'',
             creator:'',
             producer:'',
             creationDate:'',
             moddate:'',
             trapped:"", 
          };    //info 是属于doc的doc.info.XX（doc.info.XX也可以用）; 但是之前的可参看adobe的js api的143页,但是api中的都是大写的,实际用的过程中应该是小写


        //这个是doc.media,而不是app.media
var media = {
	        newPlayer : function(a){ 
		            if (a == null){ 
			          print("//[alert] CVE-2009-4324 media.newPlayer with NULL parameter"); 
		            } 
		            else { 
			          print("//[alert] warning CVE-2009-4324 media.newPlayer access"); 
		            } 
	        },
        };

Collab = {
        addStateModel : function (txt){ print ("//[alert] CVE-2009-2988 called Collab.addStateModel"); },
        removeStateModel : function (txt){ print ("//[alert] CVE-2009-2996 called Collab.removeStateModel"); },
	collectEmailInfo : function (txt){ print ("//[alert] CVE-2007-5659 called Collab.collectEmailInfo"); },
	getIcon : function (i){ print("//[alert] CVE-2009-0927 called collab.getIcon ") },
        GetCosObj : function (i){ print("//[alert] CVE-2008-4318 called collab.GetCosObj ") },
}


spell = {
           customDictionaryOpen:function(a,b){
                    print ("//[alert] CVE-2009-1493  spell.customDictionaryOpen\n"); 
           },
}


exportDataObject = function(){
    print ("//[alert] warning CVE-NO-MATCH call to exportDataObject, possible social engineering");
};


Export = function(){ print("//[alert] CVE-2009－2993 doc.Export"); }

syncAnnotScan = function(){}


getAnnot = function(pageNo,name){
            if (name in zzzannot2){
                return zzzannot2[name];
            }
            if (zzzannot.length > pageNo){
               return zzzannot[pageNo][0]; 
            }
}


getAnnots = function(){ 
		for (var i = 0; i < arguments.length; i++){
                  npage = -1;
                   if (typeof arguments[i] == 'number'){
                    npage = arguments[i];
                   }
                   else if ('nPage' in arguments[i]){
                      npage = arguments[i].nPage;
                   }
                   if (npage > -1){
			if (page_list.length > npage){
				return page_list[npage].annots;
			}
		   }
		}
}


//从api上给出的例子来看.貌似所有doc下的东西都应该是能通过this引用的
doc = {
        info : info,
        media : media,
        Collab : Collab,
        spell : spell,
        exportDataObject :exportDataObject,
        Export : Export,
	syncAnnotScan : syncAnnotScan,
        getAnnot : getAnnot,
	getAnnots : getAnnots,
};
 

var intervalExec = '';
var app = {
        doc : doc,
	viewerVersion:Number(8.0),
        viewerType:String('Reader'),
	setTimeOut:function(txt,wait){ print ("/*** called setTimeout with " + txt + ", " + wait + " */\n"); eval(txt); },
	clearTimeOut:function(a){},
        clearInterval:function(a){},
	eval:function(a){eval(a);},
        plugIns : [],
        alert : function(a){
                                PDF_alert_pattern = /^[\[]+$/;
                                if (PDF_alert_pattern.exec(a)) {
                                   print("//[alert] CVE-2009-3431 a large number of [ characters in the arguments to the alert method")
                                }
                },
        setInterval: function(fn,time){
	                        if (time > 500){
		                  //delay until the end of execution
		                   intervalExec += fn;
		                   print("/*** called setInterval with " + fn + ", " + time + " (delaying) */\n");
	                         }
	                        else {
                                    print("/*** called setInterval with " + fn + ", " + time + " */\n");
		                    eval(fn);		
	                        }
                      },
       checkForUpdate:function(a,b){
                             print ("//[alert] CVE-2008-2042  app.checkForUpdate"); },

};


this.setTimeout= app.setTimeout
this.setInterval = app.setInterval;

function PlugIn(name,filename){
    this.name = name;
    this.path = "/C/Program Files/Adobe Reader 8.0/Reader/plug_ins/" + filename;
    this.version = 8;
    this.certified = false;
    this.loaded = true;
    this.toString = function(){ return this.path; }
    this.valueOf = function(){ return this.path; }
}
app.plugIns.push(new PlugIn('Accessibility','Accessibility.api'));
app.plugIns.push(new PlugIn('Forms','AcroForm.api'));
app.plugIns.push(new PlugIn('Annots','Annots.api'));
app.plugIns.push(new PlugIn('Checkers','Checkers.api'));
app.plugIns.push(new PlugIn('DIGSIG','DigSig.api'));
app.plugIns.push(new PlugIn('ADBE:DictionaryValidationAgent','DVA.api'));
app.plugIns.push(new PlugIn('eBook','eBook.api'));
app.plugIns.push(new PlugIn('EScript','EScript.api'));
app.plugIns.push(new PlugIn('EWH','EWH32.api'));
app.plugIns.push(new PlugIn('AcroHLS','HLS.api'));
app.plugIns.push(new PlugIn('InetAxes','IA32.api'));
app.plugIns.push(new PlugIn('SVG','ImageViewer.api'));
app.plugIns.push(new PlugIn('Make Accessible','MakeAccessible.api'));
app.plugIns.push(new PlugIn('Multimedia','Multimedia.api'));
app.plugIns.push(new PlugIn('PDDom','PDDom.api'));
app.plugIns.push(new PlugIn('ppklite','PPKLite.api'));
app.plugIns.push(new PlugIn('ReadOutLoud','ReadOutLoad.api'));
app.plugIns.push(new PlugIn('Reflow','reflow.api'));
app.plugIns.push(new PlugIn('SaveAsRTF','SaveAsRTF.api'));
app.plugIns.push(new PlugIn('ADBE_Search','Search.api'));
app.plugIns.push(new PlugIn('ADBE_Search5','Search5.api'));
app.plugIns.push(new PlugIn('SendMail','SendMail.api'));
app.plugIns.push(new PlugIn('Spelling','Spelling.api'));
app.plugIns.push(new PlugIn('Updater','Updater.api'));
app.plugIns.push(new PlugIn('WebLink','weblink.api'));

function Page(){}
function Annotation(){}

var event = {};
event.target = {};
event.target.unescape = unescape;
String.eval = eval;//sample 052f2aa998c22e72e43de2a6124b7fa0

this.numPages = 0;
var getPageNthWord = function(page,word) { return zzzpages[page][word]; }
var getPageNumWords = function(page) { print ("//[alert] info getPageNumWords("+page+")"); return zzzpages[page].length; }




